var t = function (t) {
  return (t = t.toString())[1] ? t : "0".concat(t)
};

function e(t) {
  return (t = t.toString())[1] ? t : "".concat(t)
}
module.exports = {
  formatTime: function (e) {
    var n = e.getFullYear(),
      a = e.getMonth() + 1,
      r = e.getDate(),
      o = e.getHours(),
      u = e.getMinutes(),
      g = e.getSeconds();
    return "".concat([n, a, r].map(t).join("/"), " ").concat([o, u, g].map(t).join(":"))
  },
  formatDate: function (e) {
    var n = e.getFullYear(),
      a = e.getMonth() + 1,
      r = e.getDate(),
      o = e.getHours(),
      u = e.getMinutes();
    return "".concat([n, a, r].map(t).join("-"), " ").concat([o, u].map(t).join(":"))
  },
  randomRange: function (t, e) {
    for (var n = "", a = e ? Math.round(Math.random() * (e - t)) + t : t, r = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"], o = 0; o < a; o++) {
      n += r[Math.round(Math.random() * (r.length - 1))]
    }
    return n
  },
  formatDates: function (t) {
    return [t.getMonth() + 1].map(e).join("/")
  },
  formatYear: function (e) {
    return [e.getFullYear()].map(t)
  },
  formatExpect: function (e) {
    var n = e.getFullYear(),
      a = e.getMonth() + 4,
      r = e.getDate(),
      o = e.getHours(),
      u = e.getMinutes();
    return "".concat([n, a, r].map(t).join("-"), " ").concat([o, u].map(t).join(":"))
  },
  formatnow: function (e) {
    var n = e.getFullYear(),
      a = e.getMonth() + 1,
      r = e.getDate();
    return "".concat([n, a, r].map(t).join("-"))
  },
  formatStamp: function (t) {
    var e = new Date(t);
    return e.getFullYear() + "-" + ((e.getMonth() + 1 < 10 ? "0" + (e.getMonth() + 1) : e.getMonth() + 1) + "-") + ((e.getDate() < 10 ? "0" + e.getDate() : e.getDate()) + " ") + ((e.getHours() < 10 ? "0" + e.getHours() : e.getHours()) + ":") + (e.getMinutes() < 10 ? "0" + e.getMinutes() : e.getMinutes())
  },
  formatDay: function (t) {
    return [t.getDate()].map(e).join("/")
  },
  formatMsgTime: function (t) {
    var e,
      n = t.replace(/T/g, " ").replace(/\.[\d]{3}Z/, "").replace(/(-)/g, "/"),
      a = new Date(n),
      r = a.getFullYear(),
      o = a.getMonth() + 1,
      u = a.getDate(),
      g = (a.getHours(), a.getMinutes(), a.getSeconds(), new Date);
    return (e = Date.parse(g.toString()) - a) <= 6e4 ? "刚刚" : 6e4 < e && e <= 36e5 ? Math.round(e / 6e4) + "分钟前" : 36e5 < e && e <= 864e5 ? Math.round(e / 36e5) + "小时前" : 864e5 < e && e <= 1296e6 ? Math.round(e / 864e5) + "天前" : e > 1296e6 && r == g.getFullYear() ? o + "-" + u : r + "-" + o + "-" + u
  },
  formatExpects: function (e) {
    var n = e.getFullYear(),
      a = e.getMonth() + 1,
      r = e.getDate(),
      o = e.getHours(),
      u = e.getMinutes();
    return "".concat([n, a, r].map(t).join("-"), " ").concat([o, u].map(t).join(":"))
  }
};